var amplitude=function(){"use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,t){for(var n=0;n>6|192):(t+=String.fromCharCode(i>>12|224),t+=String.fromCharCode(i>>6&63|128)),t+=String.fromCharCode(63&i|128))}return t},G=function(e){for(var t="",n=0,i=0,o=0,r=0;n>2,r=(3&t)<<4|(n=e.charCodeAt(c++))>>4,s=(15&n)<<2|(i=e.charCodeAt(c++))>>6,a=63&i,isNaN(n)?s=a=64:isNaN(i)&&(a=64),u=u+W._keyStr.charAt(o)+W._keyStr.charAt(r)+W._keyStr.charAt(s)+W._keyStr.charAt(a);return u},decode:function(e){try{if(window.btoa&&window.atob)return decodeURIComponent(escape(window.atob(e)))}catch(e){}return W._decode(e)},_decode:function(e){var t,n,i,o,r,s,a="",u=0;for(e=e.replace(/[^A-Za-z0-9+/=]/g,"");u>4,n=(15&o)<<4|(r=W._keyStr.indexOf(e.charAt(u++)))>>2,i=(3&r)<<6|(s=W._keyStr.indexOf(e.charAt(u++))),a+=String.fromCharCode(t),64!==r&&(a+=String.fromCharCode(n)),64!==s&&(a+=String.fromCharCode(i));return a=G(a)}},$=Object.prototype.toString;function J(e){switch($.call(e)){case"[object Date]":return"date";case"[object RegExp]":return"regexp";case"[object Arguments]":return"arguments";case"[object Array]":return"array";case"[object Error]":return"error"}return null===e?"null":void 0===e?"undefined":e!=e?"nan":e&&1===e.nodeType?"element":"undefined"!=typeof Buffer&&"function"==typeof Buffer.isBuffer&&Buffer.isBuffer(e)?"buffer":t(e=e.valueOf?e.valueOf():Object.prototype.valueOf.apply(e))}var Q,H={DISABLE:0,ERROR:1,WARN:2,INFO:3},X=H.WARN,Z={error:function(e){X>=H.ERROR&&Y(e)},warn:function(e){X>=H.WARN&&Y(e)},info:function(e){X>=H.INFO&&Y(e)}},Y=function(e){try{console.log("[Amplitude] "+e)}catch(e){}},ee=function(e){return"string"===J(e)&&e.length>_?e.substring(0,_):e},te=function(e){var t=J(e);if("object"!==t)return Z.error("Error: invalid properties format. Expecting Javascript object, received "+t+", ignoring"),{};if(Object.keys(e).length>b)return Z.error("Error: too many properties (more than 1000), ignoring"),{};var n={};for(var i in e)if(i in e){var o=i,r=J(o);"string"!==r&&(o=String(o),Z.warn("WARNING: Non-string property key, received type "+r+', coercing to string "'+o+'"'));var s=ie(o,e[i]);null!==s&&(n[o]=s)}return n},ne=["nan","function","arguments","regexp","element"],ie=function e(t,n){var i=J(n);if(-1!==ne.indexOf(i))Z.warn('WARNING: Property key "'+t+'" with invalid value type '+i+", ignoring"),n=null;else if("undefined"===i)n=null;else if("error"===i)n=String(n),Z.warn('WARNING: Property key "'+t+'" with value type error, coercing to '+n);else if("array"===i){for(var o=[],r=0;r>16)+(t>>16)+(n>>16)<<16|65535&n}function a(e,t,n,i,o,r){return l((s=l(l(t,e),l(i,r)))<<(a=o)|s>>>32-a,n);var s,a}function d(e,t,n,i,o,r,s){return a(t&n|~t&i,e,t,o,r,s)}function h(e,t,n,i,o,r,s){return a(t&i|n&~i,e,t,o,r,s)}function f(e,t,n,i,o,r,s){return a(t^n^i,e,t,o,r,s)}function v(e,t,n,i,o,r,s){return a(n^(t|~i),e,t,o,r,s)}function u(e,t){var n,i,o,r,s;e[t>>5]|=128<>>9<<4)]=t;var a=1732584193,u=-271733879,c=-1732584194,p=271733878;for(n=0;n>5]>>>t%32&255);return n}function p(e){var t,n=[];for(n[(e.length>>2)-1]=void 0,t=0;t>5]|=(255&e.charCodeAt(t/8))<>>4&15)+i.charAt(15&t);return o}function n(e){return unescape(encodeURIComponent(e))}function o(e){return c(u(p(t=n(e)),8*t.length));var t}function r(e,t){return function(e,t){var n,i,o=p(e),r=[],s=[];for(r[15]=s[15]=void 0,16r.options.sessionTimeout)&&(r.options.unsetParamsReferrerOnNewSession&&r._unsetUTMParams(),r._newSession=!0,r._sessionId=t,r.options.saveParamsReferrerOncePerSession&&r._trackParamsAndReferrer()),r.options.saveParamsReferrerOncePerSession||r._trackParamsAndReferrer(),r.options.saveEvents&&(tt(r._unsentEvents),tt(r._unsentIdentifys)),r._lastEventTime=t,st(r),r._pendingReadStorage=!1,r._sendEventsIfReady();for(var n=0;ni.length;--o){var r=n.slice(n.length-o).join(".");me(this._cookieName,null,{domain:"."+r})}me(this._cookieName,null,{})}},et.prototype._getInitialDeviceId=function(e,t){if(e)return e;if(this.options.deviceIdFromUrlParam){var n=this._getDeviceIdFromUrlParam(this._getUrlParams());if(n)return n}return this.options.deviceId?this.options.deviceId:t||fe()};var tt=function(e){for(var t=0;t=this.options.eventUploadThreshold?(this.sendEvents(),!0):(this._updateScheduled||(this._updateScheduled=!0,setTimeout(function(){this._updateScheduled=!1,this.sendEvents()}.bind(this),this.options.eventUploadPeriodMillis)),!1):(this.sendEvents(),!0))},et.prototype._getFromStorage=function(e,t){return e.getItem(t+this._storageSuffix)},et.prototype._setInStorage=function(e,t,n){e.setItem(t+this._storageSuffix,n)};var it=function(e){if(e._useOldCookie){var t=e.cookieStorage.get(e._oldCookiename);"object"!==J(t)||rt(e,t)}else{var n=e._metadataStorage.load();"object"===J(n)&&rt(e,n)}},ot=function(e){var t=e.cookieStorage.get(e._oldCookiename);"object"===J(t)&&(rt(e,t),st(e))},rt=function(e,t){t.deviceId&&(e.options.deviceId=t.deviceId),t.userId&&(e.options.userId=t.userId),null!==t.optOut&&void 0!==t.optOut&&!1!==t.optOut&&(e.options.optOut=t.optOut),t.sessionId&&(e._sessionId=parseInt(t.sessionId,10)),t.lastEventTime&&(e._lastEventTime=parseInt(t.lastEventTime,10)),t.eventId&&(e._eventId=parseInt(t.eventId,10)),t.identifyId&&(e._identifyId=parseInt(t.identifyId,10)),t.sequenceNumber&&(e._sequenceNumber=parseInt(t.sequenceNumber,10))},st=function(e){var t={deviceId:e.options.deviceId,userId:e.options.userId,optOut:e.options.optOut,sessionId:e._sessionId,lastEventTime:e._lastEventTime,eventId:e._eventId,identifyId:e._identifyId,sequenceNumber:e._sequenceNumber};e._useOldCookie?e.cookieStorage.set(e.options.cookieName+e._storageSuffix,t):e._metadataStorage.save(t)};et.prototype._initUtmData=function(e,t){e=e||this._getUrlParams(),t=t||this.cookieStorage.get("__utmz");var n,i,o,r,s,a,u,c,p,l,d,h=(i=e,o=(n=t)?"?"+n.split(".").slice(-1)[0].replace(/\|/g,"&"):"",s=(r=function(e,t,n,i){return ue(e,t)||ue(n,i)})(L,i,"utmcsr",o),a=r(M,i,"utmcmd",o),u=r(K,i,"utmccn",o),c=r(z,i,"utmctr",o),p=r(F,i,"utmcct",o),l={},(d=function(e,t){ae(t)||(l[e]=t)})(L,s),d(M,a),d(K,u),d(z,c),d(F,p),l);return at(this,h),h},et.prototype._unsetUTMParams=function(){var e=new je;e.unset(U),e.unset(L),e.unset(M),e.unset(K),e.unset(z),e.unset(F),this.identify(e)};var at=function(e,t){if("object"===J(t)&&0!==Object.keys(t).length){var n=new je;for(var i in t)t.hasOwnProperty(i)&&(n.setOnce("initial_"+i,t[i]),n.set(i,t[i]));e.identify(n)}};et.prototype._getReferrer=function(){return document.referrer},et.prototype._getUrlParams=function(){return location.search},et.prototype._saveGclid=function(e){var t=ue("gclid",e);if(!ae(t)){var n={gclid:t};return at(this,n),n}},et.prototype._saveFbclid=function(e){var t=ue("fbclid",e);if(!ae(t)){var n={fbclid:t};return at(this,n),n}},et.prototype._getDeviceIdFromUrlParam=function(e){return ue(j,e)},et.prototype._getReferringDomain=function(e){if(ae(e))return null;var t=e.split("/");return 3<=t.length?t[2]:null},et.prototype._saveReferrer=function(e){if(!ae(e)){var t={referrer:e,referring_domain:this._getReferringDomain(e)};return at(this,t),t}},et.prototype.saveEvents=function(){try{var e=JSON.stringify(this._unsentEvents.map(function(e){return e.event}));this._setInStorage(Te,this.options.unsentKey,e)}catch(e){}try{var t=JSON.stringify(this._unsentIdentifys.map(function(e){return e.event}));this._setInStorage(Te,this.options.unsentIdentifyKey,t)}catch(e){}},et.prototype.setDomain=function(e){if(this._shouldDeferCall())return this._q.push(["setDomain"].concat(Array.prototype.slice.call(arguments,0)));if(le(e,"domain","string"))try{this.cookieStorage.options({expirationDays:this.options.cookieExpiration,secure:this.options.secureCookie,domain:e,sameSite:this.options.sameSiteCookie}),this.options.domain=this.cookieStorage.options().domain,it(this),st(this)}catch(e){se.error(e)}},et.prototype.setUserId=function(e){if(this._shouldDeferCall())return this._q.push(["setUserId"].concat(Array.prototype.slice.call(arguments,0)));try{this.options.userId=null!=e&&""+e||null,st(this)}catch(e){se.error(e)}},et.prototype.setGroup=function(e,t){if(this._shouldDeferCall())return this._q.push(["setGroup"].concat(Array.prototype.slice.call(arguments,0)));if(this._apiKeySet("setGroup()")&&le(e,"groupType","string")&&!ae(e)){var n={};n[e]=t;var i=(new je).set(e,t);this._logEvent(I,null,null,i.userPropertiesOperations,n,null,null,null)}},et.prototype.setOptOut=function(e){if(this._shouldDeferCall())return this._q.push(["setOptOut"].concat(Array.prototype.slice.call(arguments,0)));if(le(e,"enable","boolean"))try{this.options.optOut=e,st(this)}catch(e){se.error(e)}},et.prototype.setSessionId=function(e){if(le(e,"sessionId","number"))try{this._sessionId=e,st(this)}catch(e){se.error(e)}},et.prototype.resetSessionId=function(){this.setSessionId((new Date).getTime())},et.prototype.regenerateDeviceId=function(){if(this._shouldDeferCall())return this._q.push(["regenerateDeviceId"].concat(Array.prototype.slice.call(arguments,0)));this.setDeviceId(fe())},et.prototype.setDeviceId=function(e){if(this._shouldDeferCall())return this._q.push(["setDeviceId"].concat(Array.prototype.slice.call(arguments,0)));if(le(e,"deviceId","string"))try{ae(e)||(this.options.deviceId=""+e,st(this))}catch(e){se.error(e)}},et.prototype.setUserProperties=function(e){if(this._shouldDeferCall())return this._q.push(["setUserProperties"].concat(Array.prototype.slice.call(arguments,0)));if(this._apiKeySet("setUserProperties()")&&le(e,"userProperties","object")){var t=ce(de(e));if(0!==Object.keys(t).length){var n=new je;for(var i in t)t.hasOwnProperty(i)&&n.set(i,t[i]);this.identify(n)}}},et.prototype.clearUserProperties=function(){if(this._shouldDeferCall())return this._q.push(["clearUserProperties"].concat(Array.prototype.slice.call(arguments,0)));if(this._apiKeySet("clearUserProperties()")){var e=new je;e.clearAll(),this.identify(e)}};var ut=function(e,t){for(var n=0;nthis.options.sessionTimeout)&&(this._sessionId=p),this._lastEventTime=p,st(this);var l=this._ua.browser.name,d=this._ua.browser.major,h=this._ua.os.name;i=i||{},n=v({},n||{},v({},this._apiPropertiesTrackingOptions)),t=t||{},o=o||{},r=r||{};var f={device_id:this.options.deviceId,user_id:this.options.userId,timestamp:p,event_id:u,session_id:this._sessionId||-1,event_type:e,version_name:ct(this,"version_name")&&this.options.versionName||null,platform:ct(this,"platform")?this.options.platform:null,os_name:ct(this,"os_name")&&l||null,os_version:ct(this,"os_version")&&d||null,device_model:ct(this,"device_model")&&h||null,device_manufacturer:(ct(this,"device_manufacturer"),null),language:ct(this,"language")?this.options.language:null,carrier:(ct(this,"carrier"),null),api_properties:n,event_properties:ce(de(t)),user_properties:ce(de(i)),uuid:function e(t){return t?(t^16*Math.random()>>t/4).toString(16):([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,e)}(),library:{name:"amplitude-js",version:Ze},sequence_number:c,groups:ce(pe(o)),group_properties:ce(de(r)),user_agent:this._userAgent};return e===I||e===S?(this._unsentIdentifys.push({event:f,callback:a}),this._limitEventsQueued(this._unsentIdentifys)):(this._unsentEvents.push({event:f,callback:a}),this._limitEventsQueued(this._unsentEvents)),this.options.saveEvents&&this.saveEvents(),this._sendEventsIfReady(a),u}catch(e){se.error(e)}else"function"===J(a)&&a(0,"No request sent",{reason:"Missing eventType"})};var ct=function(e,t){return!!e.options.trackingOptions[t]},pt=function(e){for(var t=["city","country","dma","ip_address","region"],n={},i=0;ithis.options.savedMaxCount&&e.splice(0,e.length-this.options.savedMaxCount).forEach(function(e){"function"===J(e.callback)&&e.callback(0,"No request sent",{reason:"Event dropped because options.savedMaxCount exceeded. User may be offline or have a content blocker"})})},et.prototype.logEvent=function(e,t,n){return this._shouldDeferCall()?this._q.push(["logEvent"].concat(Array.prototype.slice.call(arguments,0))):this.logEventWithTimestamp(e,t,null,n)},et.prototype.logEventWithTimestamp=function(e,t,n,i){return this._shouldDeferCall()?this._q.push(["logEventWithTimestamp"].concat(Array.prototype.slice.call(arguments,0))):this._apiKeySet("logEvent()")?le(e,"eventType","string")?ae(e)?("function"===J(i)&&i(0,"No request sent",{reason:"Missing eventType"}),-1):this._logEvent(e,t,null,null,null,null,n,i):("function"===J(i)&&i(0,"No request sent",{reason:"Invalid type for eventType"}),-1):("function"===J(i)&&i(0,"No request sent",{reason:"API key not set"}),-1)},et.prototype.logEventWithGroups=function(e,t,n,i){return this._shouldDeferCall()?this._q.push(["logEventWithGroups"].concat(Array.prototype.slice.call(arguments,0))):this._apiKeySet("logEventWithGroups()")?le(e,"eventType","string")?this._logEvent(e,t,null,null,n,null,null,i):("function"===J(i)&&i(0,"No request sent",{reason:"Invalid type for eventType"}),-1):("function"===J(i)&&i(0,"No request sent",{reason:"API key not set"}),-1)};var lt=function(e){return!isNaN(parseFloat(e))&&isFinite(e)};et.prototype.logRevenueV2=function(e){if(this._shouldDeferCall())return this._q.push(["logRevenueV2"].concat(Array.prototype.slice.call(arguments,0)));if(this._apiKeySet("logRevenueV2()"))if("object"===J(e)&&e.hasOwnProperty("_q")&&(e=ut(new Qe,e)),e instanceof Qe){if(e&&e._isValidRevenue())return this.logEvent(T,e._toJSONObject())}else se.error("Invalid revenue input type. Expected Revenue object but saw "+J(e))},et.prototype.logRevenue=function(e,t,n){return this._shouldDeferCall()?this._q.push(["logRevenue"].concat(Array.prototype.slice.call(arguments,0))):this._apiKeySet("logRevenue()")&<(e)&&(void 0===t||lt(t))?this._logEvent(T,{},{productId:n,special:"revenue_amount",quantity:t||1,price:e},null,null,null,null,null):-1},et.prototype.removeEvents=function(e,t,n,i){dt(this,"_unsentEvents",e,n,i),dt(this,"_unsentIdentifys",t,n,i)};var dt=function(e,t,n,i,o){if(!(n<0)){for(var r=[],s=0;sn?r.push(a):a.callback&&a.callback(i,o)}e[t]=r}};et.prototype.sendEvents=function(){if(this._apiKeySet("sendEvents()")){if(this.options.optOut)this.removeEvents(1/0,1/0,0,"No request sent",{reason:"Opt out is set to true"});else if(0!==this._unsentCount()&&!this._sending){this._sending=!0;var e=(this.options.forceHttps?"https":"https:"===window.location.protocol?"https":"http")+"://"+this.options.apiEndpoint,n=Math.min(this._unsentCount(),this.options.uploadBatchSize),t=this._mergeEventsAndIdentifys(n),i=t.maxEventId,o=t.maxIdentifyId,r=JSON.stringify(t.eventsToSend.map(function(e){return e.event})),s=(new Date).getTime(),a={client:this.options.apiKey,e:r,v:w,upload_time:s,checksum:Me(w+this.options.apiKey+r+s)},u=this;new Je(e,a).send(function(e,t){u._sending=!1;try{200===e&&"success"===t?(u.removeEvents(i,o,e,t),u.options.saveEvents&&u.saveEvents(),u._sendEventsIfReady()):413===e&&(1===u.options.uploadBatchSize&&u.removeEvents(i,o,e,t),u.options.uploadBatchSize=Math.ceil(n/2),u.sendEvents())}catch(e){}})}}else this.removeEvents(1/0,1/0,0,"No request sent",{reason:"API key not set"})},et.prototype._mergeEventsAndIdentifys=function(e){for(var t=[],n=0,i=-1,o=0,r=-1;t.length=this._unsentIdentifys.length,u=n>=this._unsentEvents.length;if(u&&a){se.error("Merging Events and Identifys, less events and identifys than expected");break}a?i=(s=this._unsentEvents[n++]).event.event_id:u?r=(s=this._unsentIdentifys[o++]).event.event_id:!("sequence_number"in this._unsentEvents[n].event)||this._unsentEvents[n].event.sequence_number